<template>
    <div id="query_air_time_view">
      <header class="mui-bar mui-bar-nav">
        <a class=" mui-icon  mui-pull-left  arr_left" @tap="$router.go(-1)">
        </a>
        <h1 class="mui-title">机票价格查询</h1>
      </header>
      <!--飞机查询-->
      <div class="query_box" style="margin-top: 64px">
        <div class="line" style="padding-left: 1rem">
          <div class="address" @click="select_start" style="" v-html="start_city"></div>
          <div class="icon" @click="change_lane">
            <img src="../../../assets/images/query/fj.png" />
          </div>
          <div class="address" @click="select_end" v-html="end_city"></div>

        </div>

        <div class="line input_line" @click="select_date">
          <span v-html="query_date"></span>

        </div>
        <div class="mui-btn query_btn " @click="query_func">查询时刻票价</div>
      </div>
      <transition name="slide-fade">
        <QueryAirPriceRes :list="list" v-if="show_res" @close_res="close_res_view"></QueryAirPriceRes>
      </transition>
    </div>
</template>

<script>
  let start_address_picker;
  let end_address_picker;
  let date_picker;
  import data_city3 from "../../../tools/city_lv3_data";
  import query_ajax from "../../../ajax/query_ajax";
  import QueryAirPriceRes from  "./query_air_price_res"
    export default {
        name: "query_air_time",
      data(){
          return{
            start_city: '请选择',
            end_city: '请选择',
            query_date: '请输入查询日期',
            show_res:false
          }
      },
      components:{
        QueryAirPriceRes
      },
      created(){
        start_address_picker = new mui.PopPicker({
          layer:2
        });
        end_address_picker = new mui.PopPicker({
          layer:2
        });
        date_picker = new mui.DtPicker({
          type: 'date'
        });
        start_address_picker.setData(data_city3)
        end_address_picker.setData(data_city3)
      },
      methods:{
        query_func(){
          query_ajax.query_air_price({
            start:this.start_city,
            end:this.end_city,
            date:this.query_date
          },res=>{
            console.log(res);
            this.list = res;
            this.show_res=true
          })
        },
        close_res_view(){
          this.show_res = false;
        },
        //选择起点
        select_start: function () {
          var that = this
          start_address_picker.show(function (SelectedItem) {
            that.start_city = SelectedItem[1].text;
          })
        },
        //选择终点
        select_end: function () {
          var that = this
          end_address_picker.show(function (SelectedItem) {
            that.end_city = SelectedItem[1].text
          })
        },
        //切换 往返
        change_lane: function () {

          var address = this.end_city;
          this.end_city = this.start_city;
          this.start_city = address;

          var code = this.end_city_code;
          this.end_city_code = this.start_city_code;
          this.start_city_code = code;

        },
        select_date: function() {
          var that = this;
          date_picker.show(function (selectItems) {
            console.log(selectItems.y);//{text: "2016",value: 2016}
            console.log(selectItems.m); //{text: "05",value: "05"}
            console.log(selectItems.d); //{text: "05",value: "05"}
            var d = selectItems.y.text + "-" + selectItems.m.text + "-" + selectItems.d.text
            that.query_date = d;
          })
        }
      }
    }
</script>

<style scoped lang="less">
  /*顶部*/

  .mui-content {
    background: #fff;
  }

  .mui-control-content .mui-loading {
    margin-top: 44px;
  }

  #sliderSegmentedControl {}

  .mui-scroll,
  .mui-scroll-wrapper {}

  .mui-slider-group {
    margin-top: 2.612rem/0.625;
  }

  .gd_nav {
    position: fixed;
    left: 0;
    top: 44px;
    height: 1.306rem/0.625;
    z-index: 99;
    background: #fff;
    color: #888888;
    border-bottom: 1px solid #c5c5c5;
  }

  #slider .gd_nav a {
    font-size: 0.453rem/0.625;
    line-height: 1.306rem/0.625;
  }

  .gd_nav #sliderSegmentedControl .mui-active {
    color: #1c83fc;
  }

  .tabs {
    padding: 0 0.4rem/0.625;
    width: 100%;
    height: 1.28rem/0.625;
    background: #fff;
    position: absolute;
    top: 1.28rem/0.625;
    left: 0;
    z-index: 99;
    right: 0;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #C5C5C5;
  }

  .tab {
    padding: 0 0.4rem/0.625;
    width: 100%;
    height: 1.28rem/0.625;
    background: #fff;
    line-height: 1.28rem/0.625;
  }

  .tab span {
    height: 0.826rem/0.625;
    line-height: 0.826rem/0.625;
    font-size: 0.373rem/0.625;
    color: #353535;
    background: #f5f5f5;
    display: inline-block;
    padding: 0 0.4rem/0.625;
    border-radius: 0.1rem/0.625;
    margin-right: 0.4rem/0.625;
  }

  .tab .active {
    color: #fff;
    background: #1c83fc;
  }
  /*列表*/

  .gd_list {
    background: #fff;
  }

  .gd_list li a {
    padding: 0.4rem/0.625;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #C5C5C5;
  }

  .gd_list li .l {
    width: 3.173rem/0.625;
    height: 1.973rem/0.625;
  }

  .gd_list li .l img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 0.1rem/0.625;
  }

  .gd_list li .r {
    width: 5.666rem/0.625;
    height: 1.973rem/0.625;
  }

  .gd_list li .r p {
    margin: 0;
    color: #353535;
  }

  .gd_list li .r .t {
    font-size: 0.373rem/0.625;
    font-weight: bold;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
  }

  .gd_list li .r .t1 {
    line-height: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    font-size: 0.293rem/0.625;
    color: #888888;
    height: 0.92rem/0.625;
  }

  .gd_list li .r .bottom p {
    font-size: 0.293rem/0.625;
    display: inline-block;
  }

  .gd_list li .r .bottom .ll {
    float: left;
  }

  .gd_list li .r .bottom .rr {
    float: right;
    display: flex;
    align-items: center;
  }

  .gd_list li .r .bottom span {
    color: #353535;
  }

  .gd_list li .r .bottom .browse {
    margin-left: 0.266rem/0.625;
    display: flex;
    align-items: center;
  }

  .gd_list li .r .bottom .browse i {
    width: 0.32rem/0.625;
    height: 0.23rem/0.625;
    background: url(../../../assets/images/gd_browse_icon.png) no-repeat;
    background-size: 100% 100%;
    display: inline-block;
    margin-right: 0.08rem/0.625;
  }

  .gd_list li .r .bottom .rr i {
    font-size: 0.35rem/0.625;
    color: #1d83fc;
  }

  #slider {
    background: #fff;
    overflow: visible;
  }

  #sliders {
    background: #fff;
    overflow: visible;
  }

  .mui-slider-indicator.mui-segmented-control {
    border-bottom: 1px solid #c5c5c5;
    height: 1.38rem/0.625;
  }

  .mui-scroll {
    height: 1.28rem/0.625;
  }

  #slider .top_nav {
    text-align: left;
    white-space: nowrap;
    position: absolute;
    top: 0px;
    left: 0;
    background: #fff;
    color: #888888;
    z-index: 10;
    height: 1.28rem/0.625;
    display: flex;
  }

  .top_nav span {
    display: inline-block;
    line-height: 1.28rem/0.625;
    margin: 0 0.4rem/0.625;
  }

  .top_nav .active {
    color: #1c83fc;
    border-bottom: 4px solid #1c83fc;
  }
  /*内容*/

  .con {}

  .mui-grid-view.mui-grid-9 {
    background: #fff;
  }
  /*表单*/

  .mk_form {
    width: 9.2rem/0.625;
    margin: 0 auto;
    padding: 0 0.266rem/0.625;
    background: #fff;
    border-radius: 0.13rem/0.625;
    margin-top: 0.533rem/0.625;
  }

  .mk_form form {
    display: inline-block;
  }

  .mk_form p {
    margin-top: 0.506rem/0.625;
    margin-bottom: 0;
  }

  .mk_form input[type='text'] {
    height: 0.826rem/0.625;
    text-indent: 0.2rem/0.625;
  }

  .mk_form label {
    color: #353535;
    font-size: 0.453rem/0.625;
  }

  .mk_form input[type='submit'] {
    width: 100%;
    height: 1.253rem/0.625;
    font-size: 0.453rem/0.625;
    background: #000;
    border-color: #000;
    margin: 0.933rem/0.625 0 1.306rem/0.625 0;
  }

  .deader_nav {}
  /*视频列表*/

  .clear {
    clear: both;
    height: 0;
    font-size: 0;
    line-height: 0;
    visibility: hidden;
    overflow: hidden;
  }
  /*顶部*/

  .bd_top_s_img {
    height: 4.666rem/0.625;
  }

  .bd_top_s_img img {
    height: 100%;
    width: 100%;
    border-radius: 0.1rem/0.625;
  }

  .bd_shipin_top {
    padding: 0.533rem/0.625 0.4rem/0.625 0;
  }

  .bd_shipin {
    background: #FFFFFF;
  }

  .top_s_zi_h3 {
    font-size: 0.373rem/0.625;
    color: #353535;
    margin-top: 0.3rem/0.625;
  }

  .top_s_zi_time {
    color: #6a6a6a;
    font-size: 0.293rem/0.625;
  }

  .top_s_zi_all {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .top_s_zi_sc img {
    height: 0.4rem/0.625;
    width: 0.45rem/0.625;
  }

  .top_s_zi_sc {
    display: flex;
    align-items: center;
    color: #6a6a6a;
    font-size: 0.293rem/0.625;
  }

  .top_s_zi_sc span {
    color: #6a6a6a;
  }

  .top_s_zi_sc i {
    font-size: 0.3rem/0.625;
  }

  .bd_shipin_ul {
    border-top: 1px solid #f4f4f4;
    margin-top: 0.266rem/0.625;
    padding: 0 0.4rem/0.625;
  }

  .bd_shipin_li {
    border-bottom: 1px solid #f4f4f4;
    padding: 0.4rem/0.625 0;
    display: flex;
  }

  .bd_shipin_li_img {
    height: 2.1rem/0.625;
    width: 3.373rem/0.625;
    margin: 0 0.1rem/0.625;
  }

  .bd_shipin_li_img img {
    height: 100%;
    width: 100%
  }

  .bd_shipin_li_h3 {
    font-size: 0.416rem/0.625;
  }

  .bd_shipin_li_con {
    padding-left: 0.466rem/0.625;
    box-sizing: border-box;
    width: 5.84rem/0.625;
  }

  .bd_shipin_li_p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .query_box {
    width: 9.2rem/0.625;
    height: 5.333rem/0.625;
    box-shadow: 0 0 0.16rem/0.625 #ccc;
    margin-left: 0.4rem/0.625;
    margin-top: 0.4rem/0.625;
    padding-top: 0.5333rem/0.625;
  }

  .line {
    overflow: hidden;
  }

  .line .address {
    width: 3.333rem/0.625;
    height: 1.2rem/0.625;
    float: left;
    border-bottom: 1px solid #dcdcdc;
    text-align: center;
    line-height: 1.2rem/0.625;
  }

  .line .icon {
    width: 1.2rem/0.625;
    height: 1.2rem/0.625;
    float: left;
  }

  .line .icon img {
    width: 80%;
    margin-left: 10%;
  }

  .input_line {
    border-bottom: 1px solid #dcdcdc;
    width: 7.85rem/0.625;
    margin-left: 0.6rem/0.625;
    line-height: 1.2rem/0.625;
  }

  .input_line span {
    padding-left: 0.6rem/0.625;
    font-size: 0.34rem/0.625;
  }

  .query_btn {
    width: 7.85rem/0.625;
    margin-left: 0.6rem/0.625;
    margin-top: 0.6rem/0.625;
    border-color: #1C83FC;
    color: #1C83FC;
  }
</style>
